/**
 * 
 */
package bancosys.tec.services.implementor.descriptor;


import jmine.tec.di.resolver.ObjectResolver;
import jmine.tec.di.scope.TypedScope;
import jmine.tec.di.wrapper.Wrapper;
import bancosys.tec.component.Controller;
import bancosys.tec.component.ControllerLocator;

/**
 * Resolver para controllers
 * 
 * @author MarceloT
 */
final class ControllerResolver implements ObjectResolver {
    private final ControllerLocator locator;

    /**
     * @param locator Controllerlo
     */
    ControllerResolver(ControllerLocator locator) {
        this.locator = locator;
    }

    /**
     * @param properties {@link TypedScope}
     * @return boolean
     */
    public boolean isResolvable(TypedScope properties) {
        return true;
    }

    /**
     * {@inheritDoc}
     * 
     * @see jmine.tec.di.cache.TypeMatch#isTypeCompatible(java.lang.Class)
     */
    public boolean isTypeCompatible(Class<?> declaredRawType) {
        return Controller.class.isAssignableFrom(declaredRawType);
    }

    /**
     * @param properties {@link TypedScope}
     * @param wrapper {@link Wrapper}
     * @param requiredComponentClass type
     * @return Object
     */
    public Object resolveObject(TypedScope properties, Wrapper wrapper, Class<?> requiredComponentClass) {
        return this.locator.findControllerForClass(requiredComponentClass);
    }

    /**
     * {@inheritDoc}
     */
    public boolean isStatic() {
        return true;
    }

}